@isTest
public class MergeOpportunityControllerTest {

    static testMethod void MergeOpportunityControllerTest () {

        //创建客户
        Account acc = TestUtils.createAccount();
        acc.Level__c = '一级医院';
        insert acc;

        String accid = acc.Id;

        //创建业务机会
        Opportunity opp1 = TestUtils.createOpportunity();
        opp1.Name = 'TestOpp1';
        opp1.AccountId = acc.Id;
        opp1.NewName__c = 'xxx';
        insert opp1;

        Opportunity opp2 = TestUtils.createOpportunity();
        opp2.Name = 'TestOpp2';
        opp2.AccountId = acc.Id;
        insert opp2;

        Opportunity opp3 = TestUtils.createOpportunity();
        opp3.Name = 'TestOpp3';
        opp3.AccountId = acc.Id;
        insert opp3;

        Opportunity opp4 = TestUtils.createOpportunity();
        opp4.Name = 'TestOpp4';
        opp4.AccountId = acc.Id;
        insert opp4;
        
  //页面测试

        PageReference page = new PageReference('/apex/MergeOpportunities?accountid=' + accid);
        System.Test.setCurrentPage(page);
        MergeOpportunityController moc = new MergeOpportunityController(new ApexPages.StandardController(new Opportunity()));

        moc.accid = accid;

        moc.query();
        moc.next();
        moc.beanlist[0].checkbox = true; 
        moc.beanlist[1].checkbox = true; 


        moc.next();
        PageReference page2= new PageReference('/apex/MergeOpportunitiesTwo?accid=' + acc.id +'&id1=' +opp1.Id +'&id2=' +opp2.Id +'&id3=' +opp3.Id );
        System.Test.setCurrentPage(page2);
        MergeOpportunityTwoController twoc = new MergeOpportunityTwoController();
        twoc.init();

        System.debug('MergeOpportunitiesTwo==>'+twoc.beanlist.size());

        for(MergeOpportunityTwoController.OppBean ob :twoc.beanlist ){

          ob.chk1 = true;
         
        }
        twoc.save1();
        twoc.cancel();



        moc.cancle();


        delete opp4;
        delete opp3;
        delete opp2;






    }
}